package com.cn.yunhe.redis.study;

import java.util.HashSet;
import java.util.Set;
import org.junit.Test;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;

public class Demo4 {
	private static JedisCluster jc;
	static {
		// 只给集群里一个实例就可以
		Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
		jedisClusterNodes.add(new HostAndPort("192.168.119.128", 7000));
		jedisClusterNodes.add(new HostAndPort("192.168.119.128", 7001));
		jedisClusterNodes.add(new HostAndPort("192.168.119.128", 7002));
		jedisClusterNodes.add(new HostAndPort("192.168.119.128", 7003));
		jedisClusterNodes.add(new HostAndPort("192.168.119.128", 7004));
		jedisClusterNodes.add(new HostAndPort("192.168.119.128", 7005));

		jc = new JedisCluster(jedisClusterNodes);
	}
	@Test
	public void RedisClusterDemo() {
		// JedisCluster jc =RedisClient.getRedisClient().getJedisCluster();
		jc.set("key001", "123456");
		System.out.println(jc.get("key001"));
		// 输出helloRedis
	}
}
